﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="AchievementPage.aspx.cs" Inherits="FBKPI.Pages.AchievementPage" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
<script type="text/javascript">
    var oTable;
    $(document).ready(function () {
        mainmenu("#nav ul", "#nav li");
        mainmenu("#menu_wrap ul", "#menu_wrap li");

        //datatable section
        oTable = $("#KPIAssignDetailTable").dataTable({
            "oLanguage": {
                "sZeroRecords": "No records to display",
                "sSearch": "Search"
            },
            "bSort": true,
            "bPaginate": true,
            "bAutoWidth": false,
            "bProcessing": true,
            "bServerSide": true,
            "bDestroy": true,
            "bJQueryUI": true,
            "sPaginationType": "full_numbers",
            "bDeferRender": true,
            "fnServerData": function (sSource, aoData, fnCallback) {
                $.ajax({
                    "dataType": 'json',
                    "type": "GET",
                    "url": "../Serializer/KPIAssignDetailByUserIDSerializer.ashx?CurrentUser=" + $("#txt_user").val() + "&Year=" + $("#txt_selectyear").val(),
                    "data": aoData,
                    "success": fnCallback
                });
            },
            "aoColumns": [{
                "mData": "No"
            }, {
                "mData": "KPIDescription"
            }, {
                "mData": "AssignedTo"
            }, {
                "mData": "isActive"
            }, {
                "mData": "UoM"
            }, {
                "mData": "UoMMax"
            }, {
                "mData": "UoMMin"
            }, {
                "mData": "Periode"
            }, {
                "mData": "Year"
            }, {
                "mData": "ScoredBySystem"
            }, {
                "mData": "Weight"
            }, {
                "mData": "KPI"
            }, {
                "mData": "KPIAssign"
            }, {
                "mData": "KPIAssignDetail"
            }],
            "aoColumnDefs": [{
                "fnRender": function (oObj) {
                    return "<a href=\"#\" onclick=\"DirectTo('" + oObj.aData["KPI"] + "','" + oObj.aData["KPIAssign"] + "','" + oObj.aData["KPIAssignDetail"] + "', '" + $("#txt_user").val() + "')\"><img src='../images/detail.png' /></a>";
                },
                "aTargets": [11]
            }, {
                "fnRender": function (oObj) {
                    if (oObj.aData["isActive"] == 'True') {
                        return "<img src='../images/check.png' />"
                    } else {
                        return "<img src='../images/cross.png' />"
                    }
                },
                "aTargets": [3]
            }, {
                "fnRender": function (oObj) {
                    if (oObj.aData["ScoredBySystem"] == 'True') {
                        return "<img src='../images/check.png' />"
                    } else {
                        return "<img src='../images/cross.png' />"
                    }
                },
                "aTargets": [9]
            }, {
                "sClass": "center",
                "aTargets": [0, 3, 9, 10, 11]
            }, {
                "bVisible": false,
                "aTargets": [12, 13]
            }]
        });

        //mark selected row
        $('body').on("click", '#KPIAssignDetailTable tbody tr', function () {
            $('#KPIAssignDetailTable tbody tr').removeClass("row_selected");
            $(this).addClass("row_selected");
        });
        //--------------------end of mark selected row-----------------------------
        $("#KPIAssignDetailTable_filter label").after('&nbsp;KPI Year: <input id=\"txt_selectyear\" oninput=\'GetList($(this).val());\' type=\"text\" \>');
        //--------------------end of datatable section-----------------------------------------
        DirectTo = function (KPIID, KPIAssignID, KPIAssignDetailID, user) {
            document.location = "../Pages/InputAchievementPage.aspx?User=" + user + "&KPI=" + KPIID + "&KPIAssign=" + KPIAssignID + "&KPIAssignDetail=" + KPIAssignDetailID;
            return false;
        }
    });

    GetList = function (value) {
        if (value.length > 0) {
            var xx = '0123456789';
            if (xx.indexOf(value[value.length - 1]) < 0) {
                $("#txt_selectyear").val(value.toString().replace(value[value.length - 1], ''));
            }

            if (value.length == 4) {
                oTable.fnDraw();
            }
        }
        else
        { oTable.fnDraw(); }
    }
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div id="kpiassigndetailtable"> 
        <div>
            <div class="customPageHeader">
                <span class="customPageTitle">KPI Achievement</span>
            </div>
            <div class="ui-widget-content">
                <table cellpadding="0" cellspacing="0" class="display" id="KPIAssignDetailTable">
                    <thead>
                        <tr>
                            <th>
                                No
                            </th>
                            <th>
                                KPI Description
                            </th>
                            <th>
                                Assigned To
                            </th>
                            <th>
                                is Active
                            </th>
                            <th>
                                UoM
                            </th>
                            <th>
                                UoM Max
                            </th>
                            <th>
                                UoM Min
                            </th>
                            <th>
                                Period
                            </th>
                            <th>
                                Year
                            </th>
                            <th>
                                Scored By System
                            </th>
                            <th>
                                Weight
                            </th>
                            <th>
                            </th>
                        </tr>
                    </thead>
                    <tbody>
                    </tbody>
                </table>       
            </div>
        </div>
        <br />
    </div>
</asp:Content>
